package com.julian.iteratorPattern;

import java.util.Iterator;

public class DinnerMenu implements Menu{
    static final int MAX_ITEMS = 6;
    int numberOfItems = 0;
    MenuItem[] menuItems;

    public DinnerMenu() {
        this.menuItems = new MenuItem[MAX_ITEMS];
        addItems("Vegetarian BLT","(Fakin) Bacon with letture & tomato on whole wheat",
                true,2.99);
        addItems("BLT","Bacon with letture & tomato on whole wheat",
                false,2.99);
        addItems("Soup of the day","Soup of the day ,with a side of potato salad",
                false,3.29);
        addItems("Hotdog","A hot dog, with a side of patato salad",
                false,3.29);
    }

    public void addItems(String name, String description, boolean vegetarian, double price){
        MenuItem menuItem = new MenuItem(name,description,vegetarian,price);
        if(numberOfItems >= MAX_ITEMS){
            System.err.println("Sorry,menu is full! can not add item to menu");
        }else {
            menuItems[numberOfItems] = menuItem;
            numberOfItems++;
        }
    }

    @Override
    public Iterator createIterator(){
        return new DinerMenuIterator(menuItems);
    }
//    public MenuItem[] getMenuItems() {
//        return menuItems;
//    }


}
